package com.cib.process.bean;

import com.cib.process.chat.bean.TTSActionResult;
import com.sun.xml.internal.ws.api.pipe.NextAction;
import lombok.Data;

import java.io.Serializable;
@Data
public class ServiceResult implements Serializable {
    private String resultCode;
    private String resultMessage;
    private String sesisonId;
    private String nextAction;
    private Object nextResult;
    private String cvvStatus;

    private static  final String SUCCESS="0";

    public ServiceResult(String code, String msg, String nextAction) {
        this.resultCode=code;
        this.resultMessage=msg;
        this.nextAction=nextAction;
        this.cvvStatus=cvvStatus;
    }
    public ServiceResult(Object nextResult,String sesisonId,String nextAction){
        this.resultCode=SUCCESS;
        this.sesisonId=sesisonId;
        this.nextResult=nextResult;
        this.nextAction=nextAction;
        this.cvvStatus=cvvStatus;
    }

    public static ServiceResult buildFailedResult(IvrReturnCode ivrReturnCode) {
        String code;
        String msg;
        switch (ivrReturnCode){
            case TOKEN_EMPTY_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case PARAM_ACTION_EMPTY_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case COMMON_CHAR_REQUEST_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case START_SERV_REQ_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case QUERY_SERV_REQ_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case COMMON_CHAT_NO_AUTH:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            case BOTID_EMPTY_ERROR:
                code=ivrReturnCode.getCode();
                msg=ivrReturnCode.getMsg();
                break;
            default:
                code="666666";
                msg="commonchat fail error";
                break;

        }

        return new ServiceResult(code,msg,Actions.ERROR.getCode());

    }

    public static ServiceResult buildSuccessResult(Object nextResult, String sessionId) {
        return ServiceResult.buildSuccessResult(nextResult,sessionId, Actions.TTS.getCode());
    }

    public static ServiceResult buildSuccessResult(Object nextResult, String sessionId, String nextAction) {
        return new ServiceResult(nextResult,sessionId,nextAction);
    }





}
